package com.csust.travel.controller;

import com.csust.travel.entity.BuyerCollegeReport;
import com.csust.travel.entity.CollegeReport;
import com.csust.travel.entity.ResBean;
import com.csust.travel.mapper.BuyerCollegeReportMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("/buyercollegereport")
@CrossOrigin
@RestController
public class BuyerCollegeReportController {
    @Autowired
    BuyerCollegeReportMapper buyerCollegeReportMapper;

    @RequestMapping("/report")
    public ResBean collegeR(){
        List<BuyerCollegeReport> nameAndNumber = buyerCollegeReportMapper.findNameAndNumber();
        List<String>x = new ArrayList<>();
        List<Integer>y =new ArrayList<>();
        for (BuyerCollegeReport buyerCollegeReport : nameAndNumber) {
            x.add(buyerCollegeReport.getCollege());
            y.add(buyerCollegeReport.getValue());
        }
        Map<String,List> map = new HashMap<>();
        map.put("x",x);
        map.put("y",y);
        return new ResBean(true,null,map);

    }


}
